package testdemo;

public class Well extends Thread {

    private static volatile int num = 1;

    private void printNum() {
      // System.out.println(this.getName());
        synchronized (this) {
            for (; num < 100; num++) {
                System.out.println(
                        "当前线程是" + this.getName() + "在执行第" + num + "次操作\t" + "还剩" + (100 - num) + "次操作");
            }
        }
    }

    @Override
    public void run() {
        printNum();
    }
}
